//
//  UIImage+Add.m
//  PigMarket
//
//  Created by mac on 2019/7/3.
//  Copyright © 2019 felix.pigmarket.oc. All rights reserved.
//

#import "UIImage+Add.h"

@implementation UIImage (Add)
/**
 通过颜色设置图片
 @param color 图片颜色
 @return UIImage
 */
+ (UIImage *)imageWithColor:(UIColor *)color
{
    CGFloat imageW = 100;
    CGFloat imageH = 100;
    // 1.开启基于位图的图形上下文
    UIGraphicsBeginImageContextWithOptions(CGSizeMake(imageW, imageH), NO, 0.0);
    // 2.画一个color颜色的矩形框
    [color set];
    UIRectFill(CGRectMake(0, 0, imageW, imageH));
    // 3.拿到图片
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    // 4.关闭上下文
    UIGraphicsEndImageContext();
    return image;
}
@end
